package com.xbongbong.parent.interfaces;

import com.xbongbong.paas.field.FieldAttrEntity;
import com.xbongbong.paas.pojo.dto.FormDataAddGetDTO;
import com.xbongbong.paas.pojo.vo.FormDataAddGetVO;
import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.pro.formexplain.pojo.dto.HandlerExplainDTO;
import com.xbongbong.pro.formexplain.pojo.vo.HandlerExplainVO;
import com.xbongbong.pro.lowcodeconfig.pojo.dto.LowCodeConfigGetDTO;
import com.xbongbong.pro.lowcodeconfig.pojo.vo.LowCodeConfigGetVO;

import java.util.List;
import java.util.Map;

/**
 * 该接口用于新建页面渲染，将前端需要的字段信息处理并返回
 * @author 吴峰
 * @date 2022/01/17 11:14
 */
public interface BusinessNewPageRenderService<F> {

    /**
     *
     * @param formDataAddGetDTO
     * @return
     * @throws XbbException
     */
    FormDataAddGetVO addGet(FormDataAddGetDTO formDataAddGetDTO) throws XbbException;


    /**
     * 权限校验
     * @param formDataAddGetDTO
     * @throws XbbException
     */
    void validatePermission(FormDataAddGetDTO formDataAddGetDTO) throws XbbException;


    /**
     * 返回业务类型
     * @return
     */
    List<Integer> businessType();

    /**
     * 获取低代码配置
     * @param lowCodeConfigGetDTO
     * @return
     * @throws XbbException
     */
    LowCodeConfigGetVO getLowCodeConfig(LowCodeConfigGetDTO lowCodeConfigGetDTO) throws XbbException;
    /**
     * 获取表单
     * @param formDataAddGetDTO
     * @return
     * @throws XbbException
     */
    F getForm(FormDataAddGetDTO formDataAddGetDTO) throws XbbException;

    /**
     * 获取字段解释
     * @param formDataAddGetDTO
     * @return
     * @throws XbbException
     */
    List<FieldAttrEntity> getExplain(FormDataAddGetDTO formDataAddGetDTO) throws XbbException;

    /**
     * 处理字段解释，主要是处理可见，套餐等相关逻辑
     * @param handlerExplainDTO
     * @param form
     * @return
     * @throws XbbException
     */
    HandlerExplainVO handleExplain(HandlerExplainDTO handlerExplainDTO, F form) throws XbbException;

    /**
     * 处理字段解释，主要是处理可见，套餐等相关逻辑
     * @param formDataAddGetDTO
     * @param list
     * @return
     * @throws XbbException
     */
    void businessHandleExplain(FormDataAddGetDTO formDataAddGetDTO, List<FieldAttrEntity> list, F form) throws XbbException;

    /**
     * 获取流水号
     * @param explainMap
     * @param corpid
     * @param formId
     * @return
     * @throws XbbException
     */
    String getSerialNo(Map<String, FieldAttrEntity> explainMap, String corpid, Long formId) throws XbbException;

    /**
     * saas特殊返回字段，放在一个对象中
     * @param formDataAddGetDTO
     * @return
     * @throws XbbException
     */
    void formatSaasAttrToReturn(FormDataAddGetDTO formDataAddGetDTO, FormDataAddGetVO formDataAddGetVO, F form) throws XbbException;
}
